﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jzy.BLL.Project;
using Jzy.Model.Project;
using Jzy.Core.Common.Web;
using Frame.Lib.Utilities;


namespace Jzy.Web.Project.BugManage
{
    public partial class DoBug : PageEdit
    {
        PrjBugBO _bug = new PrjBugBO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindRad();

                PrjBugInfo info = _bug.GetInfo(PKID);
                lblRemark.Text = info.Remark;
                txtFeedback.Text = info.Feedback;
                rad.SelectedValue = info.Status.ToString();
            }
        }

        private void BindRad()
        {
            WebUtil.BindListControlWithEnum(rad, typeof(BugStatus));

            for (int i = 0; i < rad.Items.Count; i++)
            {
                if (rad.Items[i].Text == BugStatus.已关闭.ToString())
                {
                    rad.Items.RemoveAt(i);
                    i--;
                }
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            PrjBugInfo info = _bug.GetInfo(PKID);
            info.Feedback = txtFeedback.Text;
            info.Status = int.Parse(rad.SelectedValue);

            if (info.Status == (int)BugStatus.已解决)
            {
                info.RealEndTime = DateTime.Now;
            }

            _bug.Save(info);

            JSUtil.RefreshView();
        }
    }
}
